<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>呼叫中心</title>
    <style type="text/css">
        table.ebsig-text tr {
            height: 40px;
        }
    </style>
</head>

<body>

<div class="container">
    <div class="comm_content">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">会员信息</h3>
            </div>
            <div class="panel-body">
                <form class="form-inline" method="post" id="customer_form" action="/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2&operateType=<!--{$operateType}-->" onsubmit="return callcenter.search();">
                    <table class="ebsig-text">
                        <tr>
                            <!--{if isset($customer_array)}-->
                                <td width="24%" custID="<!--{$customer_array.custID}-->"> 会员名：<!--{$customer_array.custID}--></td>
                                <td width="15%">会员姓名：<!--{$customer_array.custname}--></td>
                                <td width="15%">手机：<!--{$customer_array.mobile}--></td>
                                <td width="24%"> Email：<!--{$customer_array.email}--></td>
                                <td width="20%">电话：<!--{$customer_array.phone}--></td>
                            <!--{else}-->
                                <td width="24%"  >会员名：<input type="text" class="form-control input-sm" name="custID" id="custID" value="<!--{$customer_array.custID|default:''}-->" style="width: 200px;">
                                <td width="15%">会员姓名：<input type="text" class="form-control input-sm" id="custname" name="custname" value="<!--{$arg_array.custname|default:''}-->" style="width: 100px;"></td>
                                <td width="15%">手机：<input type="text" class="form-control input-sm" id="mobile" name="mobile" value="<!--{$arg_array.mobile|default:''}-->" style="width: 100px;"></td>
                                <td width="24%"> Email：<input type="text" class="form-control input-sm" id="email" name="email" value="<!--{$arg_array.email|default:''}-->" style="width:200px;"></td>
                                <td width="20%">电话：<input type="text" class="form-control input-sm" id="phone" name="phone" value="<!--{$arg_array.phone|default:''}-->" style="width: 100px;"></td>
                            <!--{/if}-->
                        </tr>
                        <tr>
                            <td>会员余额：<span class="red"><!--{$customer_array.cashAmt|string_format:"%.2f"|default:'0.00'}--></span>元</td>
                            <td>会员积分：<span class="red"><!--{$customer_array.pointsAmt|string_format:"%.0f"|default:0}--></span></td>
                            <td>会员等级：<!--{$customer_array.rankName|default:''}--></td>
                            <td>会员折扣：<!--{$customer_array.rate|default:''}--></td>
                            <td>会员状态：
                                <!--{if !isset($customer_array)}-->
                                    &nbsp;
                                <!--{elseif $customer_array.useFlg == 1}-->
                                    可用
                                <!--{elseif $customer_array.useFlg == 2}-->
                                    禁用
                                <!--{/if}-->
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <!--{if !isset($customer_array)}-->
                                    <button type="button" onclick="callcenter.custSearch();" class="btn btn-primary btn-sm">查询</button>&nbsp;&nbsp;
                                <!--{/if}-->
                                <!--{if !isset($billPlatform)}-->
                                    <button type="button" class="btn btn-primary btn-sm" onclick="callcenter.reset();">重置</button>
                                <!--{/if}-->
                            </td>
                            <td colspan="5">
                                <!--{if isset($customer_array)}-->
                                    <!--{if isset($billPlatform) && $billPlatform eq 2}-->
                                        <button type="button" class="btn btn-primary" onclick="bill.add(<!--{$customer_array.pcustID}-->, 4 ,'');">新增订单</button>&nbsp;&nbsp;
                                    <!--{elseif isset($operateType)}-->
                                        <button type="button" class="btn btn-primary" onclick="bill.add(<!--{$customer_array.pcustID}-->, 3 ,<!--{$operateType}-->);">新增订单</button>&nbsp;&nbsp;
                                    <!--{else}-->
                                        <button type="button" class="btn btn-primary" onclick="bill.add(<!--{$customer_array.pcustID}-->, 3 ,'');">新增订单</button>&nbsp;&nbsp;
                                    <!--{/if}-->

                                    <select class="form-control input-sm" id="city_id">
                                        <!--{if isset($billPlatform)}-->
                                            <!--{foreach from=$city_array item=city}-->
                                                <option value="<!--{$city.id}-->" <!--{if $city.id eq 110}-->selected<!--{/if}-->><!--{$city.name}--></option>
                                            <!--{/foreach}-->
                                        <!--{else}-->
                                            <!--{foreach from=$city_array item=city}-->
                                                <option value="<!--{$city.id}-->"><!--{$city.name}--></option>
                                            <!--{/foreach}-->
                                        <!--{/if}-->
                                    </select>
                                <!--{else}-->
                                    <button type="button" class="btn btn-primary" onclick="callcenter.add();">新增会员</button>&nbsp;&nbsp;
                                <!--{/if}-->
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <!--{if isset($activity_info_arr) && count($activity_info_arr) > 0 }-->
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">提示信息</h3>
                </div>
                <div class="panel-body">
                    <!--{foreach  from=$activity_info_arr key=index item=activity_info}-->
                        <div style='color:red;font-size: 16px;font-weight: bold;'><!--{$index+1}-->.&nbsp&nbsp<!--{$activity_info.info}--></div><br />
                    <!--{/foreach}-->
                </div>
            </div>
            <!--{/if}-->
            <!--{if isset($customer_array)}-->
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">新增工单</h3>
                </div>
                <div class="panel-body">
                    <form id="repair_form" class="form-inline" onsubmit="return false;">
                        <input type="hidden" id="pcustID" name="pcustID" value="<!--{$customer_array.pcustID}-->">
                        <div class="form-group">
                            <label for="second_id"><span style="color:red;">*</span>工单类型：<input type="hidden" id="first_id" name="first_id" value="1"></label>
                            <select name="second_id" class="form-control " id="second_id" style="width: 150px;">
                                <option value="">请选择</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="third_id">内容： </label>
                            <select  class="form-control " name="third_id" id="third_id" style="width: 150px;">
                                <option value="">请选择</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="description">备注：</label>
                            <textarea id="description" class="form-control" name="description" placeholder="请输入备注信息" style="height:80px;width:500px;padding-left:10px;"></textarea>
                        </div>
                        <button type="submit" class="btn btn-default" style="margin-left: 40px;" onclick="repairOrder.addRepair();">新增工单</button>
                    </form>
                </div>
            </div>
            <!--{/if}-->
            <!--{if isset($customer_array)}-->
            <div id="work_order_list" style="display: none">
                <div class="panel panel-default">
                    <div class="panel-heading">工单记录</div>
                    <table class="table">
                        <thead>
                        <tr>
                            <th>创建时间</th>
                            <th>创建人</th>
                            <th>工单类型</th>
                            <th>内容</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody id="tbody">

                        </tbody>
                    </table>
                </div>
            </div>
            <!--{/if}-->

            <!--{if isset($customer_list_array)}-->
            <table id="flex1" style="display:none"></table>
            <!--{/if}-->

            <!--{if isset($customer_array)}-->
            <div class="panel panel-default">
                <div class="panel-heading">会员收货地址</div>
                <table class="table">
                    <!--{if isset($customer_array.custDeliver) && $customer_array.custDeliver}-->
                        <thead>
                        <tr>
                            <th>收件人姓名</th>
                            <th>省名</th>
                            <th>市名</th>
                            <th>区名</th>
                            <th>地址</th>
                            <th>邮编</th>
                            <th>手机</th>
                            <th>电话</th>
                        </tr>
                        </thead>
                        <tbody>
                        <!--{foreach name=deliver item=deliver from=$customer_array.custDeliver}-->
                            <tr>
                                <td><!--{$deliver.custName|default:''}--></td>
                                <td><!--{$deliver.provinceName|default:''}--></td>
                                <td><!--{$deliver.cityName|default:''}--></td>
                                <td><!--{$deliver.countyName|default:''}--></td>
                                <td><!--{$deliver.address|default:''}--></td>
                                <td><!--{$deliver.postalCode|default:''}--></td>
                                <td><!--{$deliver.mobile|default:''}--></td>
                                <td><!--{$deliver.phone|default:''}--></td>
                            </tr>
                        <!--{/foreach}-->
                        </tbody>
                    <!--{else}-->
                        <tbody><tr><td>还没有收货地址相关信息!</td></tr></tbody>
                    <!--{/if}-->
                </table>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">会员发票</div>
                <table class="table">
                    <!--{if isset($customer_array.custInvoice) && $customer_array.custInvoice}-->
                        <thead>
                        <tr>
                            <th>发票ID</th>
                            <th style="text-align: center">发票类型</th>
                            <th style="text-align: center">发票抬头类型</th>
                            <th style="text-align: center">发票抬头</th>
                        </tr>
                        </thead>
                        <tbody>
                        <!--{foreach name=invoice item=invoice from=$customer_array.custInvoice}-->
                            <tr>
                                <td><!--{$invoice.invoiceID|default:''}--></td>
                                <td style="text-align: center"><!--{$invoice.invoice_type_name|default:''}--></td>
                                <td style="text-align: center"><!--{$invoice.invoice_title_type_name|default:''}--></td>
                                <td style="text-align: center"><!--{$invoice.invoice_title|default:''}--></td>
                            </tr>
                        <!--{/foreach}-->
                        </tbody>
                    <!--{else}-->
                        <tbody><tr><td>还没有发票相关信息!</td></tr></tbody>
                    <!--{/if}-->
                </table>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">会员优惠券</div>
                <ul class="nav nav-tabs nav-justified" role="tablist" id="custInvoice">
                    <li class="active"><a href="javascript:void(0)">未使用</a></li>
                    <li class=""><a href="javascript:void(0)">已使用</a></li>
                    <li class=""><a href="javascript:void(0)">已过期</a></li>
                </ul>
                <!--未使用 开始-->
                <table class="table" id="tb_0">
                    <!--{if isset($coupon_array_no_use) && $coupon_array_no_use}-->
                        <thead>
                        <tr>
                            <th>优惠券编码</th>
                            <th>使用限额</th>
                            <th>失效日期</th>
                            <th>抵扣金额</th>
                        </tr>
                        </thead>
                        <tbody>
                        <!--{foreach name=coupon item=coupon from=$coupon_array_no_use}-->
                            <tr>
                                <td><!--{$coupon.code|default:''}--></td>
                                <td><!--{$coupon.limitMoney|string_format:"%.2f"|default:''}--></td>
                                <td><!--{$coupon.endDate|default:''}--></td>
                                <td><!--{$coupon.amount|string_format:"%.2f"|default:''}--></td>
                            </tr>
                        <!--{/foreach}-->
                        </tbody>
                    <!--{else}-->
                        <tbody><tr><td>没有未使用的优惠券!</td></tr></tbody>
                    <!--{/if}-->
                </table>
                <!--未使用 结束-->

                <!--已使用 开始-->
                <table class="table" style="display: none;" id="tb_1">
                    <!--{if isset($coupon_array_use) && $coupon_array_use}-->
                        <thead>
                        <tr><th>优惠券编码</th><th>使用限额</th><th>订单编号</th><th>截止日期</th><th>抵扣金额</th></tr>
                        </thead>
                        <tbody>
                        <!--{foreach name=coupon item=coupon from=$coupon_array_use}-->
                            <tr>
                                <td><!--{$coupon.code|default:''}--></td>
                                <td><!--{$coupon.limitMoney|string_format:"%.2f"|default:''}--></td>
                                <td><!--{$coupon.bill_code|default:''}--></td>
                                <td><!--{$coupon.endDate|default:''}--></td>
                                <td><!--{$coupon.amount|string_format:"%.2f"|default:''}--></td>
                            </tr>
                        <!--{/foreach}-->
                        </tbody>
                    <!--{else}-->
                        <tbody><tr><td>没有已使用的优惠券!</td></tr></tbody>
                    <!--{/if}-->
                </table>
                <!--已使用 结束-->

                <!--已过期 开始-->
                <table class="table" style="display: none;" id="tb_2">
                    <!--{if isset($coupon_array_past) && $coupon_array_past}-->
                        <thead>
                        <tr><th>优惠券编码</th><th>使用限额</th><th>失效日期</th><th>抵扣金额</th></tr>
                        </thead>
                        <tbody>
                        <!--{foreach name=coupon item=coupon from=$coupon_array_past}-->
                            <tr>
                                <td><!--{$coupon.code|default:''}--></td>
                                <td><!--{$coupon.limitMoney|string_format:"%.2f"|default:''}--></td>
                                <td><!--{$coupon.endDate|default:''}--></td>
                                <td><!--{$coupon.amount|string_format:"%.2f"|default:''}--></td>
                            </tr>
                        <!--{/foreach}-->
                        </tbody>
                    <!--{else}-->
                        <tbody><tr><td>没有已过期的优惠券!</td></tr></tbody>
                    <!--{/if}-->
                </table>
                <!--已过期 结束-->
            </div>
            <table id="flex2" style="display:none"></table>
        <!--{/if}-->
    </div>
</div>
<div id="pop" style="display: none;">
    <form class="form-horizontal" id="ticketForm" onsubmit="return false;">
        <div class="form-group">
            <label for="invoice_number" class="col-sm-3 control-label"><span class="red">*</span> 发票号：</label>
            <div class="col-sm-9">
                <input type="text" class="form-control w300" id="invoice_number" name="invoice_number" maxlength="100" />
                <input type="hidden" id="bill_no" name="bill_no" value="" />
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">

<!--{if isset($customer_list_array)}-->
    $("#flex1").flexigrid({
        url:"/invokingAjax-backend/customer/customer.ajax?operFlg=1&act=callcenter",
        dataType: "json",
        colModel : [
            {display: "操作", width : 230, align: "center"},
            {display: "会员号", name : "pcustID",align: "center", width : 80, sortable : true},
            {display: "会员名", width : 130},
            {display: "会员姓名", width : 80},
            {display: "会员等级", width : 60,align: "center"},
            {display: "累计消费金额", width : 80},
            {display: "会员来源", width : 60,align: "center"},
            {display: "会员类型", width : 60,align: "center"},
            {display: "手机是否验证", width : 90,align: "center"},
            {display: "省份", width : 80},
            {display: "城市", width : 80},
            {display: "地区", width : 80},
            {display: "地址", width : 230},
            {display: "email", width : 120},
            {display: "电话", width : 120},
            {display: "手机", width : 120},
            {display: "性别", width : 80,align: "center"},
            {display: "生日", width : 80,align: "center"},
            {display: "推荐人", width : 80,align: "center"}
        ],
        sortname: "pcustID",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        autoload: true,
        onSubmit: function() {
            var dt = $("#customer_form").serializeArray();
            $("#flex1").flexOptions({params: dt});
            return true;
        }
    });
<!--{/if}-->

<!--{if isset($customer_array)}-->
    $('#city_id').val(<!--{$city_id}-->);
    $("#flex2").flexigrid({
        url:"/invokingAjax-backend/bill/billSearch.ajax?operFlg=1&pcustID=<!--{$customer_array.pcustID}-->",
                dataType: "json",
            colModel : [
        {display: "操作", width : 100, align: "center"},
        {display: "订单编号", name : "bill_no", width : 140, sortable : true, align: "center"},
        {display: "订单类型", width : 100},
        {display: "订单状态", width : 80},
        {display: "订单标识", width : 80},
        {display: "支付方式", width : 120},
        {display: "代付订单号", width : 200},
        {display: "到货时间", width : 200},
        {display: "下单时间", width : 140, align: "center"},
        {display: "商品明细", width : 300},
        {display: "商品数量", width : 80},
        {display: "餐具数量", width : 80},
        {display: "蜡烛数量", width : 80},
        {display: "订单金额", width : 80},
        {display: "应收金额", width : 80},
        {display: "已收金额", width : 80},
        {display: "是否调价", width : 80},
        {display: "退货金额", width : 80},
        {display: "配送自购金额", width : 80},
        {display: "服务费", width : 60},
        {display: "城市", width : 80},
        {display: "区", width : 80},
        {display: "配送站", width : 120},
        {display: "配送员", width : 120},
        {display: "配送员手机", width : 120},
        {display: "收货人手机号码", width : 120, align: "center"},
        {display: "收货人", width : 120},
        {display: "创建人", width : 120},
        {display: "退货状态", width : 100},
        {display: "发票类型", width : 100},
        {display: "抬头类型", width : 100},
        {display: "发票抬头", width : 100},
        {display: "发票金额", width : 100},
        {display: "发票内容", width : 100},
        {display: "发 票 号", width : 100}
    ],
            sortname: "bill_no",
            sortorder: "desc",
            usepager: true,
            rp: 10,
            useRp: true,
            showTableToggleBtn: true,
            autoload: true,
            title: "会员订单列表"
    });
<!--{/if}-->

var callcenter = {
    search: function() {
        var dt = E.getFormValues("customer_form");
        if (dt.custID == "" && dt.mobile == "" && dt.custname == "" && dt.email == "" && dt.phone == "")
            return false;
        return true;
    },

    reset: function() {
        self.location = "/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2";
    },

    add: function() {
        var mobile = $('#mobile').val();
        window.open('/quanliadmin/app/customer/customer.pscript?operFlg=2&mobile='+mobile);
    },
    //点击查询，培养加提示效果
    custSearch: function() {
        E.loadding.open("正在查询，请稍后...");
        $("#customer_form").submit();
    }
};

var bill = {

    load: function() {
        $("#flex2").flexReload();
    },

    view: function( bill_no ) {
        E.open("/quanliadmin/app/bill/bill.pscript?operFlg=2&bill_no=" + bill_no, "", {height: 600, width: 1024, top: 10, left: 100});
    },

    audit: function( bill_no ) {
        this.bill_no = bill_no;
        E.confirm("您确认审核该订单吗？", "bill.confirmSudit");
    },

    confirmSudit: function() {
        E.ajax_get({
            url: "/invokingAjax-backend/bill/bill.ajax?operFlg=3",
            data: {
                bill_no: this.bill_no
            },
            call: "bill.result"
        });
    },

    result: function( o ) {
        if (o.code == 200) {
            E.alert(o.message, 2);
            bill.load();
        } else {
            E.alert(o.message);
        }
    },

    //新增订单 大客户订单弹出之前才会弹出地址列表 update by loreta.cheng 2015-06-16 start
    add: function( pcustID, operFlg ,operateType) {
        if(operateType==''){
            window.open('/quanliadmin/app/bill/billEdit.pscript?operFlg='+ operFlg +'&pcustID=' + pcustID + '&cityid=' + $('#city_id').val());
        }else{
            window.open('/quanliadmin/app/bill/billEdit.pscript?operFlg='+ operFlg +'&operateType='+operateType+'&pcustID=' + pcustID + '&cityid=' + $('#city_id').val());
        }
    },
    //大客户订单弹出之前才会弹出地址列表 update by loreta.cheng 2015-06-16 end

    alter: function(bill_no) {
        window.open('/quanliadmin/app/bill/billEdit.pscript?operFlg=1&bill_no=' + bill_no);
    },

    cancel: function( bill_no ) {
        this.bill_no = bill_no;
        E.confirm("您确认取消该订单吗？", "bill.confirmCancel");
    },

    confirmCancel: function() {
        E.ajax_get({
            url: "/invokingAjax-backend/bill/bill.ajax?operFlg=4",
            data: {
                bill_no: this.bill_no
            },
            call: "bill.result"
        });
    },

    //拒收
    rejected : function( bill_no ) {
        E.open("/quanliadmin/app/bill/billReturn.pscript?operFlg=4&bill_no=" + bill_no, "", {height: 600, width: 1024, top: 10, left: 100});
    },

    //开发票
    makeTicket: function( bill_no ){
        $('#bill_no').val(bill_no);
        //调用打开弹出层公共JS方法
        E.popup.open({
            id:"pop",   		                                             //获取id为"pop"元素内的HTML
            title: "开发票",                                               //弹出层标题
            css: "width:800px;",                                          //设置弹出层样式
            btnName: "保存",                                               //执行“确定”操作的按钮名称
            btnCall:"bill.check();"                                      //点击确定后执行的方法
        });
    },
    //验证发票
    check: function(){

        this.dt = E.getFormValues("ticketForm");
        var invoice_number = $.trim( $("#invoice_number").val() );
        var err_msg = '';

        if(invoice_number == ''){
            err_msg += '发票号不能为空，请填写<br />';
        }

        if(err_msg != ''){
            E.alert(err_msg);
        }else{
            bill.execute();
        }
    },

    //开票执行
    execute: function(){
        E.popup.close();
        //E.loadding.open("正在保存，请稍候...");
        E.ajax_post({
            url: "/invokingAjax-backend/bill/billSearch.ajax?operFlg=100",
            data: this.dt,
            call: "bill.result"
        });
    },

    //退货
    returnGoods : function( bill_no ) {
        E.open("/quanliadmin/app/bill/billReturn.pscript?operFlg=2&bill_no=" + bill_no, "", {height: 600, width: 1024, top: 10, left: 100});
    }

};

$("#custInvoice li").click(function(){

    $(this).addClass('active').siblings('li').removeClass('active');

    $("#tb_"+$(this).index()).show().siblings('table').hide();

});

var repairOrder = {

    //新增工单验证
    addRepair: function (){

        var msg = '';

        this.dt = E.getFormValues('repair_form');

        if(E.isEmpty($('#second_id').val())){
            msg += '请选择工单类型<br/>';
        }
        if(msg != ''){
            E.alert(msg);
            return;
        }
        repairOrder.repairConfirm();
    },

    repairConfirm: function(){
        E.confirm("您确认要添加新工单吗？", "repairOrder.repairSave");
    },

    //工单保存
    repairSave: function (){
        E.loadding.open("正在添加，请稍后...");
        E.ajax_post({
            url: '/invokingAjax-backend/callcenter/callcenterWorkOrder.ajax?operFlg=100',
            data:this.dt,
            call: "repairOrder.result"
        });
    },

    //返回处理结果
    result: function (o){

        E.loadding.close();
        if (o.code == 200) {
            E.popup.close();
            workOrder.search(1);
            E.alert(o.message, 2, 'repairOrder.load');
        } else {
            E.alert(o.message);
        }
    },

    load: function(){
        $('#second_id').val('');
        $('#third_id').html('<option value="">请选择</option>');
        $('#description').val('');
    }
}

<!--{if isset($customer_array)}-->
$(document).ready(function() {
    workOrder.search(1);
});
var workOrder = {
    search:function(page){

        var pid = $('#pcustID').val();

        E.ajax_get({
            url: '/invokingAjax-backend/callcenter/callcenterWorkOrder.ajax?operFlg=1',
            data: {
                pcustID: pid,
                page:page
            },
            call: function( o ) {
                if (o.code ==200 && o.data.work != null) {
                    var html = '';
                    $.each(o.data.work, function(i,val){
                        html +='<tr><td>'+val.createTime+'</td>';
                        html += '<td>'+val.creator+'</td>';
                        html += '<td>'+val.work_type_name+'</td>';
                        html += '<td>'+val.work_type_content_name+'</td>';
                        html += '<td>'+val.remark+'</td></tr>';
                    });
                    html += '<tr><td colspan="5"><div id="page">'+o.data.paging+'</div></td></tr>'
                    $('#work_order_list').css('display', 'block');
                }
                $('#tbody').html(html);
            }
        });
    }
}
<!--{/if}-->

</script>

<!--{if isset($customer_array)}-->
    <script type="text/javascript" src="/framework/ebsig/js/item.js"></script>
    <script type="text/javascript">
        get_second_item($("#first_id").val());
    </script>
<!--{/if}-->

</body>
</html>